<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <button>11</button>
    <button>22</button>


    <script>

        // []  == ![]   -> true
        // {}  == !{}   -> false





        const single = (function () {
            class Fn {
                constructor() { }
                init(str) { }
            }



            let obj = null;   // obj用来存储是否实例化了

            return function (...arg) {
                if (!obj) {
                    obj = new Fn()
                }
                obj.init(...arg)
            }
        })


        oBtn1.onclick = function () {
            single('hi')

        }

        oBtn2.onclick = function () {
            single('hello')

        }





        // (function(){

        //     for(){
        //         for(){}
        //     }
        // })()








    </script>

</body>

</html>